#!/bin/sh

# $Id: setvolume,v 1.2 2009-07-23 22:05:47 brian Exp $
# Copyright (c)2007 Brian Manning <brian at portaboom dot com>

# PLEASE DO NOT E-MAIL THE AUTHOR ABOUT THIS SOFTWARE
# The proper venue for questions is the LACK mailing list at:
# http://groups.google.com/linuxack or <linuxack.googlegroups.com>

# picks up things like colorize()
if ! [ -e $LACK_FUNCTIONS ]; then
    LACK_FUNCTIONS="/etc/scripts/lack_functions.sh"
fi # if ! [ -e $LACK_FUNCTIONS ]
source $LACK_FUNCTIONS

ACTION=$1
BINARY="/etc/scripts/setvolume.sh"
[ -x "$BINARY" ] || exit 1
BASENAME="setvolume"
DESC="ALSA Mixer Volume"
# don't mute sound by default
MUTE=0

# go into /proc/cmdline and see what options were used
# stream URL
file_parse "/proc/cmdline" "mute"
MUTE_CHECK=$PARSED
# some defaults
if [ "x$MUTE_CHECK" != "x" ]; then
    MUTE=1
fi # if [ "x$MUTE_CHECK" != "x" ]

# export these here so they get propagated to other scripts
export MUTE

# act on the argument passed in to this script
case "$ACTION" in
  vars)
    # echo out what commandline variables are parsed by this script
    echo "${BASENAME}:"
    exit 0
  ;;
  start)
    colorize $S_TIP "${BASENAME}: Starting ${DESC}"
    # mute all the channels on startup?
    if [ $MUTE -eq 0 ]; then
        # nope
        $BINARY
        check_exit_status $? $BASENAME
    else
        # yep
        $BINARY --mute
        check_exit_status $? $BASENAME
    fi # if [ "x$USE_WGET" != "x" ]
    ;;
  stop)
    colorize $S_TIP "${BASENAME}: Stopping ${DESC}"
    $BINARY --mute
    check_exit_status $? $BASENAME
    ;;
  restart|force-reload)
     $0 stop
     $0 start
    ;;
  *)
    echo "Usage: $BASENAME {start|stop|restart|force-reload}" >&2
    exit 3
    ;;
esac

exit 0
# vi: set shiftwidth=4 tabstop=4 filetype=sh :
# конец!
